package com.rrd.hive.udf.sms;

import cn.hutool.core.util.ReUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.io.IntWritable;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.rrd.hive.udf.sms.HiveUdfRegexTools.*;

@Description(
        name = "cv_sms_parse",
        value = "_FUNC_(body, address, sms_type) - Get fin_type, src_sms_flags, sub_type, " +
                "org_name, org_loan, trim_body_flags " +
                "org_name_flags, trade_type, org_type, " +
                "sms_tag, sms_bank_tag, salary_income from sms",
        extended = "Example:\n> SELECT _FUNC_( 'smsbody-代发工资-代发人民币12元', '106939837356');\n  {fin_type=12, salary_income=0, src_sms_flags=00000, phone_tag=0, org_type=16, trim_body_flags=00000000, org_loan=, sub_type=2, org_name_flags=0, sms_bank_tag=0, trade_type=7, sms_tag=0, org_name=}\n"
)
public class CvSmsParserUDF extends UDF {

    public static Configuration config() {
        System.setProperty("HADOOP_USER_NAME", "hdfs");
        Configuration conf = new Configuration();
        conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
        return conf;
    }

    public static void main(String[] args) {
        try {
//            String body = "[易借速贷]尊敬的用户，您已获得易借速贷新授信机会，立即登录易借速贷APP > hzlzkg.com/codeDX 查看，退订回T";
            String body = "【三六零借条】曲木阿木先生，您的360借条已逾期，拟将逾期信息上报央行征信系统（即金融信用信息基础数据库），请务必于今日足额还款，已还请忽略！详询：4000526663。";
//            String body = null;
            System.out.println(new CvSmsParserUDF().evaluate(body,
                    "4000526663"
                    , "1"
            ));
        } catch (HiveException e) {
            throw new RuntimeException(e);
        }


    }

    public Map<String, String> evaluate(String body, String address, String sendType) throws HiveException {
        Map<String, String> resHashMap = new HashMap<>();
        try {
            if(body != null) {
                String trimBody = hiveUdfRegExReplace(body, "\\s", "");
//                String bodyName = hiveUdfRegexResStrInPos(body.trim(), "((?<=^\\[)([^提醒|提示|流量|话费|权益]{1,8})(?=\\]))|((?<=\\[)([^提醒|提示|流量|话费|权益]{1,8})(?=\\]$))|((?<=^【)([^提醒|提示|流量|话费|权益]{1,8})(?=】))|((?<=【)([^提醒|提示|流量|话费|权益]{1,8})(?=】$))", 0);
                String orgName = getOrgName(address, trimBody);
                String salaryIncome = getSalaryIncome(orgName, trimBody);
                int smsTag = getSmsTag(sendType, body, salaryIncome);

                resHashMap.put("fin_type", ""+getFinType(body));
                resHashMap.put("src_sms_flags", getSrcSmsFlags(body));
                resHashMap.put("sub_type", ""+getSubType(body));
                resHashMap.put("org_name", orgName);
                resHashMap.put("org_loan", getOrgLoan(orgName, trimBody));
                resHashMap.put("trim_body_flags", getTrimBodyFlags(trimBody));
                resHashMap.put("org_name_flags", ""+getOrgNameFlags(orgName));
                resHashMap.put("trade_type", ""+getTradeType(trimBody));
                resHashMap.put("org_type", ""+getOrgType(orgName, trimBody));
                resHashMap.put("sms_tag", ""+smsTag);
                resHashMap.put("sms_bank_tag", ""+getSmsBankTag(body, smsTag));
                resHashMap.put("salary_income", salaryIncome);
            }
            resHashMap.put("phone_tag", ""+getPhoneTag(address));

        } catch (Exception e) {
            System.out.println("Excep: " + e.getMessage());
            e.printStackTrace(System.out);
        } finally {
            return resHashMap;
        }
    }


    public static int getFinType(String body) throws Exception {

        if (hiveUdfRegExpEx(body, "已经逾期|已逾期|已超过|已过|已超.*(天|日|期限|还款日)|已超期") == 1) {
            return 1;
        }

        if (hiveUdfRegExpEx(body, "(还款|扣款|划扣|代扣).*(失败)|(无法|未能)(还款|扣款|划扣)") == 1
                && hiveUdfRegExpEx(body, "(以免|避免).?(还款|扣款|划扣)(失败)|(余额不足时)|(如因余额不足)") == 0) {
            return 2;
        }

        if (hiveUdfRegExpEx(body, "(资金|借款).*(汇入|发放|入账)|已到账|借款成功|成功放款|(发放|支用)贷款|贷款已发放") == 1
                && hiveUdfRegExpEx(body, "过期将影响信用额度") == 0) {
            return 3;
        }

        if (hiveUdfRegExpEx(body, "(借款|放款)失败") == 1) {
            return 4;
        }

        if (hiveUdfRegExpEx(body, "(于|今|明|将|预计|还有|剩).*(日前|到期|满期|还款|扣款|超期)|(还|付)款日|提前存至|保证.*余额充足|按时还款|待付款") == 1) {
            return 5;
        }

        if (hiveUdfRegExpEx(body, "额度不足") == 1 || hiveUdfRegExpEx(body, "已超过.*额度") == 1) {
            return 6;
        }

        if (hiveUdfRegExpEx(body, "成功(还款|扣款)|(还款|扣款|结清)成功|已还清") == 1 && hiveUdfRegExpEx(body, "如已还清") == 0) {
            return 7;
        }

        if (hiveUdfRegExpEx(body, "未通过|未能通过|(信用|综合)评分不足|申请.*(失败|拒绝)|不符合|审(批|核)拒绝|(未|未能).*(获).*额度") == 1) {
            return 8;
        }

        if (hiveUdfRegExpEx(body, "已通过|(审批|审核)通过") == 1) {
            return 9;
        }

        if (hiveUdfRegExpEx(body, ".cn|.com|http") == 1) {
            return 10;
        }

        if (hiveUdfRegExpEx(body, "(更换|更改|修改|变更).*手机号|手机号.*(更换|更改|修改|变更)|新手机号") == 1) {
            return 11;
        }

        return 12;

    }

    public static String getSrcSmsFlags(String body) throws Exception {
        return "" + hiveUdfRegExpEx(body, "传票")
                + hiveUdfRegExpEx(body, "移交")
                + hiveUdfRegExpEx(body, "坐牢")
                + hiveUdfRegExpEx(body, "严重逾期")
                + hiveUdfRegExpEx(body, "不得不");
    }

    private IntWritable getSubType(String smsBody) throws Exception {
        final String pattern1 = "电信|短信|微信|卡劵|移动|联通|通卡|社保卡|工信|旗舰店|同花|信息|信访|ETC|高速|自来水|飞信|通信|王卡|停机|连信|学信网|卫生|集享卡|迪卡侬";
        final String pattern2 = "银|贷|钱|金融|卡|普惠|分期|消金|现金|借|呗|花|信|金服|白条|农商行|金条|支付";
        final String pattern3 = "还款|应还|征信|逾期案件|分期|贷款|借|利息|利率|审批|下款|用款|综合评分";


        IntWritable ret = new IntWritable(2); //other

        String pattern = "(^【.{0,10}】)|(【.{0,10}】$)|(^\\[.{0,10}\\])|(\\[.{0,10}\\]$)";
//            System.out.println("find res: " + hiveUdfRegExpEx(smsBody, pattern));

        String organ_name = hiveUdfRegexResultToString(smsBody, pattern);
        if (organ_name != null) {
            if (hiveUdfRegExpEx(organ_name, pattern1) == 0) {
                if (hiveUdfRegExpEx(organ_name, pattern2) == 1
                        || (organ_name != "" && hiveUdfRegExpEx(smsBody, pattern3) == 1)
                        || (hiveUdfRegExpEx(organ_name, "逾期") == 1 && hiveUdfRegExpEx(organ_name, "法院") == 1)) {
                    if (hiveUdfRegExpEx(organ_name, "银行") == 1
                            || hiveUdfRegExpEx(organ_name, "信用卡") == 1
                            || hiveUdfRegExpEx(organ_name, "农商行") == 1) {
                        ret.set(0); //bank
                    } else {
                        ret.set(1); //nonbank
                    }
                }
            }
        }
        return ret;
    }

    private String getSalaryIncome(String orgName, String trimBody) throws Exception {
        String res = "0";
        HashMap<String, String> singleMap = initSingleMap();
        HashMap<String, DoubleRegex> doubleMap = initDoubleMap();
        HashMap<String, DoubleRegex> tripleMap = initTripleMap();
        HashMap<String, List<DoubleRegex>> quadraeMap = initQuadraeMap();
        if (orgName == null || trimBody == null || trimBody.equals("")) {
            return res;
        }
        String salaryIncome = "";
        if (singleMap.containsKey(orgName)) {
            String pattern = singleMap.get(orgName);
            salaryIncome = hiveUdfRegexResStrInPos(trimBody, pattern, 0);
        } else if (doubleMap.containsKey(orgName)) {
            DoubleRegex doubleRegex = doubleMap.get(orgName);
            if (hiveUdfRegExpEx(trimBody, doubleRegex.getPattern1()) == 1) {
                salaryIncome = hiveUdfRegexResStrInPos(trimBody, doubleRegex.getPattern2(), 0);
            }
        } else if (tripleMap.containsKey(orgName)) {
            DoubleRegex doubleRegex = tripleMap.get(orgName);
            if (hiveUdfRegExpEx(trimBody, doubleRegex.getPattern1()) == 0) {
                salaryIncome = hiveUdfRegexResStrInPos(trimBody, doubleRegex.getPattern2(), 0);
            }
        } else if (quadraeMap.containsKey(orgName)) {
            List<DoubleRegex> doubleRegexes = quadraeMap.get(orgName);
            for (DoubleRegex regex : doubleRegexes) {
                if (regex.getSize() == 2) {
                    if (hiveUdfRegExpEx(trimBody, regex.getPattern1()) == 1) {
                        salaryIncome = hiveUdfRegexResStrInPos(trimBody, regex.getPattern2(), 0);
                        break;
                    }
                } else {
                    salaryIncome = hiveUdfRegexResStrInPos(trimBody, regex.getPattern1(), 0);
                }
            }
        } else if (orgName == "山东农商银行" || orgName == "详询96668") {
            String pattern = "\\（.*工资.*交易\\）人民币[0-9.,]+元";
            salaryIncome = hiveUdfRegexResStrInPos(trimBody, pattern, 0);
        }


        if (salaryIncome != null && salaryIncome.length() > 0) {
            String salaryPattern = "[0-9.,]+元|人民币[0-9.,]+|[0-9.,]+人民币|实发[0-9.,]+";
            String salaryPattern2 = "[0-9.,]+";
            String resSalary;
            salaryIncome = hiveUdfRegExReplace(salaryIncome, ",", "");
            if (hiveUdfRegExpEx(salaryIncome, salaryPattern) == 1) {
                String tmpSalary = hiveUdfRegexResStrInPos(salaryIncome, salaryPattern, 0);
                resSalary = hiveUdfRegexResStrInPos(tmpSalary, salaryPattern2, 0);
            } else {
                resSalary = hiveUdfRegexResStrInPos(salaryIncome, salaryPattern2, 0);
            }
            if (resSalary != null) {
                res = resSalary;
            }
        }
        return res;
    }

    public static HashMap<String, String> initSingleMap() {
        HashMap<String, String> resMap = new HashMap<>();
        resMap.put("尊宝比萨", "实发工资:[0-9.,]+");
        resMap.put("庄浪县财政局", "实发[0-9.,]+元");
        resMap.put("诸暨市邮政局,admin", "实发金额[0-9.,]+");
        resMap.put("株洲融兴村镇银行", "工资,转入[0-9.,]+元");
        resMap.put("舟山自来水公司,admin", "实发合计[0-9.,]+");
        resMap.put("重庆银行", "工资转账存入人民币[0-9.,]+元");
        resMap.put("重庆三峡银行", "工资\\（收入\\）人民币[0-9.,]+元");
        resMap.put("中智江苏", "实发工资[0-9.,]+元");
        resMap.put("中原银行", "代发工资工资[0-9.,]+元|代发工资入账[0-9.,]+元|实发工资[0-9.,]+元");
        resMap.put("中信银行", "工资存入人民币[0-9.,]+元");
        resMap.put("中通文博技术服务有限公司", "实发工资:[0-9.,]+");
        resMap.put("中通快递", "实发工资[0-9.,]+");
        resMap.put("中天合创门克庆煤矿", "应发工资:[0-9.,]+");
        resMap.put("中石化宁波分公司", "实发工资[0-9.,]+");
        resMap.put("中宁青银村镇银行", "工资[0-9.,]+元");
        resMap.put("中科生物", "实发工资[0-9.,]+");
        resMap.put("中金汇", "实发[0-9.,]+");
        resMap.put("中江融兴村镇银行", "中间业务前台工资,转入[0-9.,]+元");
        resMap.put("中集圣达因", "实发金额为:[0-9.,]+");
        resMap.put("中国邮政武冈分公司", "实发工资[0-9.,]+元");
        resMap.put("中国银行吉安分行", "实发工资[0-9.,]+");
        resMap.put("中国银行", "\\(.*工资.*\\)人民币[0-9.,]+元|\\(工资\\)\\(.*.*\\)人民币[0-9.,]+元|实际发放[0-9.,]+元|实发工资[0-9.,]+元|入账人民币[0-9.,]+元\\（代发工资\\）");
        resMap.put("中工经联人才", "实发工资[0-9.,]+");
        resMap.put("中达集团公司", "实发工资:[0-9.,]+");
        resMap.put("中车株洲电机", "实领合计[0-9.,]+");
        resMap.put("中策橡胶集团", "实发[0-9.,]+");
        resMap.put("中策清泉综合管理处,1", "实发工资[0-9.,]+ ");
        resMap.put("政务综合办公平台", "工资，金额[0-9.,]+元");
        resMap.put("郑州银行", "\\(工资\\),收款人民币[0-9.,]+元");
        resMap.put("郑机财务", "实发工资:[0-9.,]+");
        resMap.put("正源咨询", "全部薪酬合计为[0-9.,]+元");
        resMap.put("浙信村镇银行", "工资收入[0-9.,]+");
        resMap.put("浙石化", "实发[0-9.,]+元");
        resMap.put("浙江新农化工", "实发合计：[0-9.,]+");
        resMap.put("浙江五洲新春集团", "实发工资[0-9.,]+元");
        resMap.put("浙江华友钴业股份有限公司", "实发合计:[0-9.,]+");
        resMap.put("浙江方大通信", "实发[0-9.,]+");
        resMap.put("掌飞", "实发:[0-9.,]+");
        resMap.put("长子融汇村镇银行", "工资[0-9.,]+元");
        resMap.put("长治集团公司", "实发工资[0-9.,]+元");
        resMap.put("长盈精密", "实发金额: [0-9.,]+");
        resMap.put("长沙银行", "工资转入[0-9.,]+元|工资存入[0-9.,]+元");
        resMap.put("长沙艾迪康", "实发工资[0-9.,]+");
        resMap.put("长江银行", "代发工资业务，金额为[0-9.,]+元");
        resMap.put("长城华西银行", "工资人民币[0-9.,]+元|人民币[0-9.,]+元代发工资");
        resMap.put("长安银行", "到账\\(.*工资\\/奖金\\)[0-9.,]+元");
        resMap.put("章丘齐鲁村镇银行", "\\(工资\\/奖金\\)，人民币[0-9.,]+元");
        resMap.put("张家口银行", "工资，金额[0-9.,]+元|工资[0-9.,]+元");
        resMap.put("张家港农商银行", "工资代发转入人民币[0-9.,]+元|工资人民币[0-9.,]+元|工资转入人民币[0-9.,]+元");
        resMap.put("运城农行", "实发[0-9.,]+元");
        resMap.put("云南农信", "工资人民币[0-9.,]+元");
        resMap.put("云南红塔银行", "工资存入人民币[0-9.,]+元");
        resMap.put("悦通知", "应发合计:[0-9.,]+");
        resMap.put("酉阳融兴村镇银行", "工资,转入[0-9.,]+元");
        resMap.put("邮储银行", "工资公司代发金额[0-9.,]+元|工资金额[0-9.,]+元");
        resMap.put("由我科技", "实发[0-9.,]+");
        resMap.put("攸县财政局", "实发工资[0-9.,]+");
        resMap.put("甬政软件", "实发合计[0-9.,]+");
        resMap.put("永兴材料", "实发工资[0-9.,]+元");
        resMap.put("营口沿海银行", "工资存入\\（非支票\\）[0-9.,]+元");
        resMap.put("营口港", "实发工资:[0-9.,]+");
        resMap.put("银座银行", "工资发放[0-9.,]+");
        resMap.put("银川市财政局", "实发合计:[0-9.,]+");
        resMap.put("益海粮油", "实发工资[0-9.,]+");
        resMap.put("益海精细", "实发[0-9.,]+");
        resMap.put("易才集团", "实发[0-9.,]+");
        resMap.put("宜章长行村镇银行", "工资存入[0-9.,]+元");
        resMap.put("宜宾市商业银行", "工资转账存入[0-9.,]+元");
        resMap.put("宜宾商业银行", "[0-9.,]+元\\(.*工资.*\\)|工资转账存入[0-9.,]+元");
        resMap.put("依顿集团", "税后工资:[0-9.,]+");
        resMap.put("扬子江药业", "实发合计:[0-9.,]+");
        resMap.put("烟台银行", "工资\\/奖金人民币[0-9.,]+元");
        resMap.put("雅安商行", "\\(代发工资\\)增加[0-9.,]+元|代发工资增加[0-9.,]+元");
        resMap.put("迅达股份,admin", "实发工资[0-9.,]+");
        resMap.put("雪花四川", "实发工资[0-9.,]+");
        resMap.put("溆浦县财政局", "实发工资[0-9.,]+元");
        resMap.put("兴贤人才", "实发工资[0-9.,]+元");
        resMap.put("兴福村镇银行", "转账存入[0-9.,]+元\\(.*工资\\)");
        resMap.put("邢台银行", "工资(及补贴)?人民币[0-9.,]+元");
        resMap.put("新网银行", "工资人民币[0-9.,]+元");
        resMap.put("孝义汇通村镇银行", "工资[0-9.,]+元");
        resMap.put("湘西长行村镇银行", "工资存入[0-9.,]+元|工资转入[0-9.,]+元");
        resMap.put("县联社", "实发金额[0-9.,]+");
        resMap.put("西政计财处", "实发[0-9.,]+元");
        resMap.put("西平中原村镇银行", "工资[0-9.,]+元");
        resMap.put("西藏银行", "工资收入[0-9.,]+元");
        resMap.put("西安银行", "工资[0-9.,]+元");
        resMap.put("武汉农商行", "工资[0-9.,]+元");
        resMap.put("无锡农商行", "工资，金额[0-9.,]+元");
        resMap.put("乌兰察布市财政局", "实发工资总额[0-9.,]+元");
        resMap.put("乌海银行", "工资金额[0-9.,]+元");
        resMap.put("乌海市海勃湾区财政局", "实发 [0-9.,]+元");
        resMap.put("文山民丰村镇银行", "工资转入[0-9.,]+");
        resMap.put("温州银行", "[0-9.,]+交易摘要：代发工资");
        resMap.put("潍坊银行", "存入\\(.*工资.*\\)，人民币[0-9.,]+元");
        resMap.put("巍山医院,财务科", "实发合计[0-9.,]+");
        resMap.put("县联社", "实发金额[0-9.,]+");
        resMap.put("西政计财处", "实发[0-9.,]+元");
        resMap.put("西平中原村镇银行", "工资[0-9.,]+元");
        resMap.put("西藏银行", "工资收入[0-9.,]+元");
        resMap.put("西安银行", "工资[0-9.,]+元");
        resMap.put("武汉农商行", "工资[0-9.,]+元");
        resMap.put("无锡农商行", "工资，金额[0-9.,]+元");
        resMap.put("乌兰察布市财政局", "实发工资总额[0-9.,]+元");
        resMap.put("乌海银行", "工资金额[0-9.,]+元");
        resMap.put("乌海市海勃湾区财政局", "实发 [0-9.,]+元");
        resMap.put("文山民丰村镇银行", "工资转入[0-9.,]+");
        resMap.put("温州银行", "[0-9.,]+交易摘要：代发工资");
        resMap.put("潍坊银行", "存入\\(.*工资.*\\)，人民币[0-9.,]+元");
        resMap.put("巍山医院,财务科", "实发合计[0-9.,]+");
        resMap.put("兴贤人才", "实发工资[0-9.,]+元");
        resMap.put("兴福村镇银行", "转账存入[0-9.,]+元\\(.*工资\\)");
        resMap.put("邢台银行", "工资(及补贴)?人民币[0-9.,]+元");
        resMap.put("新网银行", "工资人民币[0-9.,]+元");
        resMap.put("孝义汇通村镇银行", "工资[0-9.,]+元");
        resMap.put("湘西长行村镇银行", "工资存入[0-9.,]+元|工资转入[0-9.,]+元");
        resMap.put("万荣县财政局", "实发工资[0-9.,]+");
        resMap.put("万邦医药", "实发合计[0-9.,]+");
        resMap.put("同恒金属", "实发[0-9.,]+");
        resMap.put("通源人力资源部", "实发：[0-9.,]+");
        resMap.put("通源环境", "实发：[0-9.,]+");
        resMap.put("通道县财政局", "实发工资:[0-9.,]+元");
        resMap.put("铁岭银行", "工资转入[0-9.,]+元");
        resMap.put("天津银行", "工资存入人民币[0-9.,]+元");
        resMap.put("藤县桂银村镇银行", "收入\\（.*工资\\）[0-9.,]+元");
        resMap.put("腾龙股份", "实发合计[0-9.,]+");
        resMap.put("泰航公司", "实发合计[0-9.,]+");
        resMap.put("泰安银行", "工资\\/奖金，存入[0-9.,]+元");
        resMap.put("台州银行", "工资[0-9.,]+|工资账户转入[0-9.,]+");
        resMap.put("苏州银行", "工资￥[0-9.,]+");
        resMap.put("苏州巨峰", "实际应付[0-9.,]+");
        resMap.put("四川银行凉山分行", "工资存入[0-9.,]+元");
        resMap.put("四川银行", "工资,存入[0-9.,]+元");
        resMap.put("四川南玻", "实发[0-9.,]+");
        resMap.put("四川分公司", "实发工资[0-9.,]+");
        resMap.put("顺德农商银行", "工资,入账人民币[0-9.,]+元");
        resMap.put("双峰县工资中心", "实发工资[0-9.,]+元");
        resMap.put("寿光村镇银行", "工资转入人民币[0-9.,]+元");
        resMap.put("手机工资单", "实发工资：[0-9.,]+");
        resMap.put("市二医院", "实发合计[0-9.,]+");
        resMap.put("仕邦人才", "实发工资[0-9.,]+元");
        resMap.put("始兴大众村镇银行", "工资金额[0-9.,]+元");
        resMap.put("四川农信", "到账人民币[0-9.,]+元\\(.*工资.*\\)|实发工资：[0-9.,]+元");
        resMap.put("神马电力", "实发工资[0-9.,]+");
        resMap.put("深圳农商银行", "\\（代发工资\\）人民币[0-9.,]+");
        resMap.put("深圳农商行", "转入\\（代发工资\\）人民币[0-9.,]+|转入工资人民币[0-9.,]+元");
        resMap.put("深圳宝安桂银村镇银行", "收入\\（.*工资.*\\）[0-9.,]+元");
        resMap.put("设计院", "实发[0-9.,]+");
        resMap.put("绍兴银行", "工资人民币[0-9.,]+元");
        resMap.put("韶山光大村镇银行", "工资[0-9.,]+元");
        resMap.put("上社公司人力资源部", "实发工资：[0-9.,]+");
        resMap.put("上饶银行", "\\(工资\\)[0-9.,]+元");
        resMap.put("上海银行", "工资人民币[0-9.,]+元");
        resMap.put("上海煦翔", "实发工资：[0-9.,]+");
        resMap.put("上海外服厦门分公司", "实发工资[0-9.,]+");
        resMap.put("上海外服（集团）有限公司厦门分公司", "实发[0-9.,]+|实发工资[0-9.,]+");
        resMap.put("上海佩琪", "实发工资：[0-9.,]+元");
        resMap.put("上海农商银行", "工资存入人民币[0-9.,]+元");
        resMap.put("森松公司", "实发金额[0-9.,]+");
        resMap.put("三棵树", "实发工资:[0-9.,]+");
        resMap.put("润迅", "税后实发：[0-9.,]+元");
        resMap.put("日照银行", "存入\\(.*工资.*\\)人民币[0-9.,]+|工资存入人民币[0-9.,]+元|工资\\/奖金存入人民币[0-9.,]+元");
        resMap.put("仁寿县支付中心", "实发[0-9.,]+元");
        resMap.put("泉州银行", "汇款人民币[0-9.,]+元\\（附言：.*.*x工资\\）");
        resMap.put("曲靖市商业银行", "\\(.*工资.*\\)转入[0-9.,]+元|工资[0-9.,]+元|工资入账[0-9.,]+元");
        resMap.put("青浦劳务公司", "实发[0-9.,]+");
        resMap.put("青海银行", "工资[0-9.,]+元");
        resMap.put("青海农信", "工资金额[0-9.,]+元");
        resMap.put("青岛银行", "工资[0-9.,]+元");
        resMap.put("前程无忧", "实发工资为：[0-9.,]+");
        resMap.put("奇精机械", "实发工资[0-9.,]+");
        resMap.put("齐商银行", "\\(工资\\)[0-9.,]+元|\\(工资\\/奖金\\)[0-9.,]+元");
        resMap.put("齐鲁银行", "存入\\(.*工资.*\\)，人民币[0-9.,]+元");
        resMap.put("浦发银行", "[0-9.,]+\\[银联入账:代付代发工资\\]|存人[0-9.,]+\\[.*工资.*\\]|存人[0-9.,]+元\\[.*工资.*\\]|实付合计[0-9.,]+元");
        resMap.put("浦发村镇银行", "\\（代发-工资\\）,金额[0-9.,]+元");
        resMap.put("鄱阳公安局", "实发合计[0-9.,]+");
        resMap.put("平罗农村商业银行", "实发合计:[0-9.,]+元");
        resMap.put("平顶山银行", "工资[0-9.,]+元");
        resMap.put("平昌农科村镇银行", "\\(代发工资\\)增加[0-9.,]+元");
        resMap.put("平安银行", "工资理财[0-9.,]+元|工资转入人民币[0-9.,]+元");
        resMap.put("品道餐饮", "税后实发合计:[0-9.,]+");
        resMap.put("盘锦银行", "\\(代发工资\\)转入RMB[0-9.,]+元");
        resMap.put("宁夏银行", "[0-9.,]+元\\(\\(工资\\)\\)|[0-9.,]+元\\（工资\\）|工资转入人民币[0-9.,]+元");
        resMap.put("宁夏财政厅", "实发合计:[0-9.,]+");
        resMap.put("宁波奇亿金属", "实发合计[0-9.,]+");
        resMap.put("宁波才烁", "实发工资[0-9.,]+元");
        resMap.put("内蒙古银行", "\\(.*工资.*\\)人民币[0-9.,]+元");
        resMap.put("南通中远川崎", "实发工资[0-9.,]+");
        resMap.put("南商（中国）", "工资发生存入人民币 [0-9.,]+");
        resMap.put("南山集团", "工资为[0-9.,]+元");
        resMap.put("南平移动", "实发合计[0-9.,]+元");
        resMap.put("南方人才租赁", "实发工资[0-9.,]+");
        resMap.put("南玻集团", "实发[0-9.,]+");
        resMap.put("纳杰", "实发工资[0-9.,]+");
        resMap.put("美亚光电", "实发金额[0-9.,]+");
        resMap.put("梅州客家村镇银行", "工资人民币[0-9.,]+元");
        resMap.put("麻阳县财政局", "实发工资:[0-9.,]+");
        resMap.put("鹿城农商银行", "实际到账金额\\【[0-9.,]+\\】");
        resMap.put("泸州银行", "工资入账[0-9.,]+元");
        resMap.put("临商银行", "\\(工资\\/奖金\\)人民币[0-9.,]+");
        resMap.put("辽宁农信", "[0-9.,]+元\\[.*工资\\]");
        resMap.put("莲花医院", "实发工资:[0-9.,]+");
        resMap.put("丽江财政", "实发工资：[0-9.,]+");
        resMap.put("廊坊银行", "工资存入人民币[0-9.,]+元");
        resMap.put("兰州银行", "\\(银联入账|兰州汇鑫诚|工资\\)人民币[0-9.,]+元");
        resMap.put("兰新公司", "实发工资:[0-9.,]+");
        resMap.put("莱商银行", "\\(.*工资.*\\)人民币[0-9.,]+元");
        resMap.put("昆仑银行", "工资\\(摘要:报销款\\)收入[0-9.,]+元|工资收入[0-9.,]+元");
        resMap.put("跨越速运", "实发工资[0-9.,]+元");
        resMap.put("科诺", "实发合计[0-9.,]+");
        resMap.put("康力电梯", "实发工资：[0-9.,]+");
        resMap.put("九江银行", "工资[0-9.,]+元");
        resMap.put("晋中银行", "代发工资[0-9.,]+元");
        resMap.put("晋商银行", "工资[0-9.,]+元|工资转入[0-9.,]+元");
        resMap.put("晋城银行", "转存人民币[0-9.,]+元");
        resMap.put("金堂汇金银行", "工资交易收入[0-9.,]+元");
        resMap.put("金仑集团", "实发工资[0-9.,]+");
        resMap.put("金华银行", "工资[0-9.,]+金额[0-9.,]+元");
        resMap.put("今飞轮毂", "实发工资:[0-9.,]+");
        resMap.put("叫叫管家", "实发工资[0-9.,]+元");
        resMap.put("焦作中旅银行", "工资[0-9.,]+元|实发[0-9.,]+元");
        resMap.put("焦煤集团", "实发合计[0-9.,]+元");
        resMap.put("绛县财政局", "实发工资[0-9.,]+");
        resMap.put("江阴农商银行", "代发工资业务,金额[0-9.,]+元");
        resMap.put("江阴农商行", "工资收入业务,金额[0-9.,]+元|工资业务,金额[0-9.,]+元");
        resMap.put("江西银行", "工资收入人民币[0-9.,]+元|工资转入[0-9.,]+元|收入人民币[0-9.,]+元.*附言：工资.*");
        resMap.put("江西农商银行", "工资.*\\(转入\\)人民币[0-9.,]+元|工资人民币[0-9.,]+元");
        resMap.put("福尔波西格林平湖", "实得[0-9.,]+");
        resMap.put("方城凤裕村镇银行", "存入\\(工资\\/奖金\\)人民币[0-9.,]+元");
        resMap.put("二连浩特市财政局", "实发 [0-9.,]+元");
        resMap.put("鄂尔多斯银行", "\\(.*工资.*\\)人民币[0-9.,]+元");
        resMap.put("鄂尔多斯市人大", "实发工资[0-9.,]+");
        resMap.put("东营银行", "[0-9.,]+元\\(工资\\/奖金\\)");
        resMap.put("东兴海关", "实发金额[0-9.,]+");
        resMap.put("东莞银行", "工资收入人民币[0-9.,]+元");
        resMap.put("东莞尚馥", "实发薪资[0-9.,]+");
        resMap.put("东莞农商银行", "工资\\(转入\\)[0-9.,]+元");
        resMap.put("东方中行", "实发工资[0-9.,]+元");
        resMap.put("电车公司", "实发合计:[0-9.,]+");
        resMap.put("电白区慢病中心", "实发总金额：[0-9.,]+");
        resMap.put("德州银行", "\\(.*银行工资\\/奖金\\)[0-9.,]+人民币");
        resMap.put("得力集团", "实发工资[0-9.,]+");
        resMap.put("丹东银行", "工资人民币[0-9.,]+");
        resMap.put("大连银行", "\\（.*工资\\）人民币[0-9.,]+");
        resMap.put("大连精工电子", "实发[0-9.,]+");
        resMap.put("达陕高速", "实发合计:[0-9.,]+");
        resMap.put("楚雄红塔村镇银行", "工资[0-9.,]+元");
        resMap.put("湖南农信", "工资[0-9.,]+元|工资专户转入人民币[0-9.,]+元");
        resMap.put("湖北银行", "工资[0-9.,]+元");
        resMap.put("湖北农信", "[0-9.,]+元\\(.*工资\\)|工资代发户转入[0-9.,]+元\\(.*\\)");
        resMap.put("葫芦岛银行", "工资,存入[0-9.,]+元");
        resMap.put("洪江市财政局", "实发工资[0-9.,]+元");
        resMap.put("恒丰银行", "工资收入[0-9.,]+");
        resMap.put("河南农信", "工资.{0,2}入账[0-9.,]+|工资入账[0-9.,]+");
        resMap.put("河北银行", "工资\\+[0-9.,]+元");
        resMap.put("合兴集团", "实发工资[0-9.,]+");
        resMap.put("合盛硅业", "实发工资[0-9.,]+");
        resMap.put("航空工业制动", "工资:[0-9.,]+");
        resMap.put("桂平桂银村镇银行", "收入\\（.*工资.*\\）[0-9.,]+元");
        resMap.put("桂林银行", "收入\\（.*工资.*\\）[0-9.,]+元");
        resMap.put("桂林公安交警提示", "实发金额[0-9.,]+元");
        resMap.put("贵州银行", "工资[0-9.,]+元|工资入账人民币[0-9.,]+元");
        resMap.put("贵州农信", "\\(.*工资\\)[0-9.,]+元|\\(.*工资\\)收入[0-9.,]+元|工资过渡户向您.*转入[0-9.,]+元");
        resMap.put("贵阳银行", "[0-9.,]+\\[附言：.*工资.*\\]");
        resMap.put("贵阳农商银行", "收入\\（.*工资\\）[0-9.,]+元");
        resMap.put("硅基半导体", "实发工资:[0-9.,]+");
        resMap.put("广州银行", "[0-9.,]+元\\(.*工资.*\\)");
        resMap.put("广州农商银行", "工资收入人民币[0-9.,]+元");
        resMap.put("广州锦兴纺织漂染有限公司", "实付工资[0-9.,]+");
        resMap.put("广元贵商村镇银行", "存入[0-9.,]+\\[.*工资\\]");
        resMap.put("广西前之锦", "实发合计:[0-9.,]+");
        resMap.put("沧州银行", "工资存入[0-9.,]+元");
        resMap.put("采油七厂人事科", "实发工资[0-9.,]+元");
        resMap.put("财政国库支付中心", "实发工资[0-9.,]+");
        resMap.put("贝莱胜厦门", "实发工资[0-9.,]+");
        resMap.put("北京银行", "工资收入[0-9.,]+元");
        resMap.put("北京农商银行", "工资收入[0-9.,]+元");
        resMap.put("保定银行", "工资人民币[0-9.,]+元");
        resMap.put("邦德激光", "实发工资[0-9.,]+");
        resMap.put("八亿时空", "实发合计[0-9.,]+");
        resMap.put("安福城关中学", "实发金额[0-9.,]+");
        resMap.put("安得医疗", "实发工资:[0-9.,]+");
        resMap.put("爱仕达", "实发工资：[0-9.,]+|实发工资[0-9.,]+");
        resMap.put("艾莱希斯,admin", "实发工资[0-9.,]+");
        resMap.put("O乐", "实发合计:[0-9.,]+");
        resMap.put("OPPO", "实发金额:[0-9.,]+");
        resMap.put("JJY", "工资卡工资[0-9.,]+");
        resMap.put("杭州华大海天", "实发工资[0-9.,]+");
        resMap.put("杭州朝阳橡胶", "最终实发[0-9.,]+");
        resMap.put("汉中移动", "实发合计：[0-9.,]+");
        resMap.put("汉口银行", "\\(.*工资\\)[0-9.,]+元");
        resMap.put("邯郸银行", "\\(代发工资\\)存入[0-9.,]+元");
        resMap.put("海峡银行", "工资存入[0-9.,]+元");
        resMap.put("成都银行", "工资人民币[0-9.,]+元");
        resMap.put("成都农商银行", "工资收入[0-9.,]+元");
        resMap.put("朝阳银行", "代发工资[0-9.,]+元");
        resMap.put("朝晖公司,admin", "综合工资[0-9.,]+");
        resMap.put("常州康辉医疗", "实发工资[0-9.,]+");
        resMap.put("海南农信社", "[0-9.,]+元\\(工资\\)|实发[0-9.,]+");
        resMap.put("海南海药", "实发合计[0-9.,]+");
        resMap.put("海口京玉", "实发工资[0-9.,]+元");
        resMap.put("海丰农商银行", "\\（代发工资\\）人民币[0-9.,]+");
        resMap.put("海底捞", "实发合计[0-9.,]+");
        resMap.put("华光新材", "工资:[0-9.,]+");
        resMap.put("沪农商村镇银行", "工资存入人民币[0-9.,]+元");
        resMap.put("湖州银行", "工资金额[0-9.,]+元");
        resMap.put("湖商村镇银行", "工资交易,收入人民币[0-9.,]+");
        resMap.put("龙海广电网络", "实发工资[0-9.,]+");
        resMap.put("六安钢铁薪资", "工资[0-9.,]+元");
        resMap.put("嘉兴银行", "\\(.*工资\\)人民币[0-9.,]+");
        resMap.put("家家悦", "工资[0-9.,]+");
        resMap.put("佳士科技", "实发[0-9.,]+");
        resMap.put("济宁银行", "\\(工资\\/奖金\\)[0-9.,]+元");
        resMap.put("吉林银行", "工资存入￥[0-9.,]+元");
        resMap.put("江苏摩比斯", "实际支付：[0-9.,]+");
        resMap.put("江南银行", "工资人民币[0-9.,]+元|入账\\(.*工资.*\\)人民币[0-9.,]+元");
        resMap.put("建新赵氏", "实发合计[0-9.,]+");
        resMap.put("赣州银行", "工资金额[0-9.,]+元");
        resMap.put("甘州财政", "实发工资[0-9.,]+元");
        resMap.put("甘肃银行平凉分行", "实发工资[0-9.,]+元");
        resMap.put("甘肃银行", "工资[0-9.,]+元|工资人民币[0-9.,]+元");
        resMap.put("甘肃信合", "工资人民币[0-9.,]+元");
        resMap.put("盖州农商银行", "实发工资[0-9.,]+");
        resMap.put("曲靖惠民村镇银行", "工资转入[0-9.,]+元");
        resMap.put("武安村镇银行", "\\(.*工资\\)增加[0-9.,]+元");
        resMap.put("枣庄银行", "存入\\(工资\\/奖金\\)[0-9.,]+元");
        resMap.put("天津武清村镇银行", "存入\\(.*工资.*\\)，人民币[0-9.,]+元");
        resMap.put("山西农信", "工资:[0-9.,]+元");
        resMap.put("绵阳市商业银行", "工资人民币[0-9.,]+元|[0-9.,]+元\\(.*工资\\)");
        resMap.put("厦门银行", "工资[0-9.,]+元");
        resMap.put("陵城圆融村镇银行", "\\(代发工资\\)增加[0-9.,]+元");
        resMap.put("广发银行", "收入人民币[0-9.,]+元\\(.*工资\\)");
        resMap.put("广发卡中心人资部", "实发[0-9.,]+元");
        resMap.put("广东农信", "工资收入人民币[0-9.,]+元|向您.*账户发放工资[0-9.,]+元");
        resMap.put("广东南粤银行", "\\(.*工资\\)[0-9.,]+元");
        resMap.put("济宁儒商村镇银行", "工资\\/奖金[0-9.,]+元");
        resMap.put("香河益民村镇银行", "\\(代发工资\\)增加[0-9.,]+元");
        resMap.put("江苏颂德企业服务", "实发工资[0-9.,]+元");
        resMap.put("淮河能源", "实发工资[0-9.,]+");
        resMap.put("怀化市财政局", "实发工资[0-9.,]+元");
        resMap.put("基久南京分公司", "实发数[0-9.,]+");
        resMap.put("徽商银行", "工资[0-9.,]+元");
        resMap.put("古汉山矿", "实发:[0-9.,]+");
        resMap.put("公司HR", "实发工资[0-9.,]+");
        resMap.put("工资条", "实发工资[0-9.,]+");
        resMap.put("工行海南省分行", "实发[0-9.,]+");
        resMap.put("崇义章源钨业", "实发合计[0-9.,]+元");
        resMap.put("澄迈县财政局", "实发工资[0-9.,]+");
        resMap.put("安康移动人力部", "实发：[0-9.,]+|实发工资：[0-9.,]+");
        resMap.put("阜新银行", "工资人民币[0-9.,]+元");
        resMap.put("抚顺银行", "[0-9.,]+元,工资");
        resMap.put("广西华业建筑工程有限公司", "实发工资[0-9.,]+");
        resMap.put("嘉艺上海包装制品有限公司", "实发工资[0-9.,]+");
        resMap.put("海宁市邮政局,嘉兴派遣公司", "实发[0-9.,]+");
        resMap.put("海宁市邮政局,admin", "实发[0-9.,]+");
        resMap.put("华润雪花广东公司", "实发工资[0-9.,]+");
//        //new add
//        resMap.put("山东农商银行","\\（.*工资.*交易\\）人民币[0-9.,]+元");
//        resMap.put("详询96668","\\（.*工资.*交易\\）人民币[0-9.,]+元");
        return resMap;
    }

    public static HashMap<String, DoubleRegex> initDoubleMap() {
        HashMap<String, DoubleRegex> resMap = new HashMap<>();
        resMap.put("珠海华润银行", new DoubleRegex("摘要：.*工资", "人民币[0-9.,]+元"));
        resMap.put("长沙银行", new DoubleRegex("付款人：.*工资发放中心", "转账转入[0-9.,]+元"));
        resMap.put("威海市商业银行", new DoubleRegex("(工资\\/奖金)", "存入人民币[0-9.,]+元"));
        resMap.put("盛京银行", new DoubleRegex(".*工资.*", "转入人民币[0-9.,]+元"));
        resMap.put("厦门国际银行", new DoubleRegex("附言：.*工资.*", "金额CNY[0-9.,]+"));
        resMap.put("宁波银行", new DoubleRegex("业务种类=工资|业务种类=代发工资", "发生额=[0-9.,]+"));
        resMap.put("南京银行", new DoubleRegex("摘要：.*工资.*", "收到.*汇入的[0-9.,]+元|收入[0-9.,]+元"));
        resMap.put("民生银行", new DoubleRegex(".*工资.*", "存入￥[0-9.,]+元"));
        resMap.put("蒙商银行", new DoubleRegex(".*工资", "存入￥[0-9.,]+元|存入人民币[0-9.,]+元"));
        resMap.put("龙江银行", new DoubleRegex("工资发放业务", "转入人民币[0-9.,]+"));
        resMap.put("柳州银行", new DoubleRegex("摘要：工资|\\（摘要：.*工资.*\\）", "转入[0-9.,]+元|[0-9.,]+元\\（摘要：.*工资\\）"));
        resMap.put("兰州银行", new DoubleRegex("备注为.*工资", "转入人民币[0-9.,]+元"));
        resMap.put("交通银行", new DoubleRegex("摘要：.*工资|附言：.*工资", "转入[0-9.,]+元|转入资金[0-9.,]+元"));
        resMap.put("江苏银行", new DoubleRegex("摘要：\\[.*工资.*\\]", "转入人民币[0-9.,]+元"));
        resMap.put("吉林农信", new DoubleRegex("摘要：.*工资", "存入[0-9.,]+元"));
        resMap.put("华夏银行", new DoubleRegex("代发工资", "收入人民币[0-9.,]+元"));
        resMap.put("湖南三湘银行", new DoubleRegex("备注：代发工资", "转入￥[0-9.,]+|转入金额：CNY[0-9.,]+"));
        resMap.put("海南银行", new DoubleRegex("备注：.*工资", "入账[0-9.,]+元"));
        resMap.put("哈尔滨银行", new DoubleRegex("\\[工资\\]", "转入人民币[0-9.,]+元"));
        resMap.put("广西农信", new DoubleRegex("付方：.*工资.*|摘要：工资|绩效", "收入[0-9.,]+元"));
        resMap.put("广西北部湾银行", new DoubleRegex("摘要：.*工资", "金额：[0-9.,]+"));
        resMap.put("光大银行", new DoubleRegex("摘要:.*工资.*", "存入[0-9.,]+元|转入[0-9.,]+元"));
        resMap.put("富滇银行", new DoubleRegex("备注：.*工资.*", "收入￥[0-9.,]+"));
        resMap.put("承德银行", new DoubleRegex("备注:.*工资.*", "入账[0-9.,]+元"));
        resMap.put("微众银行", new DoubleRegex("备注：工资", "转入[0-9.,]+元"));
        resMap.put("长葛轩辕村镇银行", new DoubleRegex("附言：工资", "转入人民币[0-9.,]+元"));
        return resMap;
    }

    public static HashMap<String, DoubleRegex> initTripleMap() {
        HashMap<String, DoubleRegex> resMap = new HashMap<>();
        resMap.put("中国农业银行", new DoubleRegex("工资支付", "工资.*交易人民币[0-9.,]+|工资交易人民币[0-9.,]+|工资单已产生，实发[0-9.,]+元|工资奖金交易人民币[0-9.,]+|实发[0-9.,]+"));
        resMap.put("工商银行", new DoubleRegex("支出", "\\（.*工资\\）[0-9.,]+元|\\(.*工资.*\\)[0-9.,]+元"));
        return resMap;
    }

    private static HashMap<String, List<DoubleRegex>> initQuadraeMap() {
        HashMap<String, List<DoubleRegex>> resMap = new HashMap<>();
        resMap.put("重庆农村商业银行", Arrays.asList(new DoubleRegex("付款方:.*工资专户", "\\[存入\\][0-9.,]+元"),
                new DoubleRegex("\\[.*工资\\][0-9.,]+元")));
        resMap.put("浙商银行", Arrays.asList(new DoubleRegex("摘要工资", "增加人民币[0-9.,]+元"),
                new DoubleRegex("备注：\\（工资\\）", "转账[0-9.,]+元"),
                new DoubleRegex("增加人民币[0-9.,]+元\\（“工资”\\）")));
        resMap.put("浙江农信", Arrays.asList(new DoubleRegex("对方:.*工资专户", "收入[0-9.,]+"),
                new DoubleRegex("工资收入[0-9.,]+")));
        resMap.put("招商银行", Arrays.asList(new DoubleRegex("备注：.*工资.*", "汇款人民币[0-9.,]+"),
                new DoubleRegex("工资，人民币[0-9.,]+|入账工资\\(.*\\)，人民币[0-9.,]+")));
        resMap.put("兴业银行", Arrays.asList(new DoubleRegex("对方户名:.*\\（.*工资.*\\）", "汇入收入[0-9.,]+元"),
                new DoubleRegex("工资收入\\（工资\\）[0-9.,]+元|工资收入[0-9.,]+元")));
        resMap.put("鄞州银行", Arrays.asList(new DoubleRegex("\\（代发工资\\）", "代发[0-9.,]+元"),
                new DoubleRegex("工资专用账户转入[0-9.,]+元")));
        resMap.put("唐山银行", Arrays.asList(new DoubleRegex("摘要：.*工资.*", "存入[0-9.,]+元"),
                new DoubleRegex("工资[0-9.,]+元")));
        resMap.put("泰隆银行", Arrays.asList(new DoubleRegex("汇出账户.*工资专户", "资金汇入人民币[0-9.,]+元"),
                new DoubleRegex("代发工资转入人民币[0-9.,]+元|工资.*转入人民币[0-9.,]+元")));
        resMap.put("遂宁银行", Arrays.asList(new DoubleRegex("代发工资", "代发人民币[0-9.,]+元"),
                new DoubleRegex("工资", "转入人民币[0-9.,]+元")));
        resMap.put("四川天府银行", Arrays.asList(new DoubleRegex("备注:.*工资", "转账收入[0-9.,]+元"),
                new DoubleRegex("工资代发收入[0-9.,]+元")));
        resMap.put("陕西信合", Arrays.asList(new DoubleRegex("备注:.*工资.*|附言.*工资", "转入[0-9.,]+元"),
                new DoubleRegex("附言\\[工资\\]", "转入[0-9.,]+元")));
        resMap.put("山西银行", Arrays.asList(new DoubleRegex("\\(.*工资.*\\)", "转存人民币[0-9.,]+元"),
                new DoubleRegex("代发工资:[0-9.,]+元|工资￥[0-9.,]+元|代发工资[0-9.,]+元")));
        resMap.put("江苏农信", Arrays.asList(new DoubleRegex("备注:.*工资.*|\\[备注：工资\\/奖金\\]", "入账人民币[0-9.,]+元\\(付方:.*|转入人民币[0-9.,]+元"),
                new DoubleRegex("入账人民币[0-9.,]+元\\(付方:.*\\）\\[.*工资.*\\]")));
        resMap.put("建设银行", Arrays.asList(new DoubleRegex("附言：.*工资", "存入人民币[0-9.,]+元|收入人民币[0-9.,]+元"),
                new DoubleRegex("工资.*收入人民币[0-9.,]+元|工资收入人民币[0-9.,]+元|工资.*存入人民币[0-9.,]+元|实发[0-9.,]+|实发工资[0-9.,]+元|工资\\/奖金\\（.*\\）收入[0-9.,]+元")));
        resMap.put("华融湘江银行", Arrays.asList(new DoubleRegex("对方留言为：转工资钱|付款方.*工资专户", "汇款人民币[0-9.,]+元|转账存入人民币[0-9.,]+元"),
                new DoubleRegex("工资存入[0-9.,]+元")));
        resMap.put("黄河银行", Arrays.asList(new DoubleRegex("\\（.*工资\\）", "转入[0-9.,]+元"),
                new DoubleRegex("工资过渡户转入[0-9.,]+元")));
        resMap.put("杭州银行", Arrays.asList(new DoubleRegex("款项内容为工资", "发起人民币[0-9.,]+元汇款"),
                new DoubleRegex("存入[0-9.,]+元\\(工资\\)")));
        resMap.put("福建农信", Arrays.asList(new DoubleRegex("对方户名:.*工资.*", "代发收入[0-9.,]+元"),
                new DoubleRegex("工资收入[0-9.,]+元|财政收入[0-9.,]+元")));
        resMap.put("稠州银行", Arrays.asList(new DoubleRegex("付款人:.*工资专户", "转账收入RMB[0-9.,]+"),
                new DoubleRegex("工资收入RMB[0-9.,]+")));
        resMap.put("常熟农商银行", Arrays.asList(new DoubleRegex("\\（.*工资.*\\）", "存入[0-9.,]+元"),
                new DoubleRegex("[0-9.,]+元\\(.*工资\\)")));
        resMap.put("安徽农金", Arrays.asList(new DoubleRegex("付款方:.*工资.*", "转账收入[0-9.,]+元"),
                new DoubleRegex("代发工资[0-9.,]+元|工资收入[0-9.,]+元")));
        return resMap;
    }


    private final static Map<String, String> dimOrgName = new HashMap<String, String>() {{
        put("10086", "中国移动");
        put("10010", "中国联通");
        put("10001", "中国电信");
        put("95559", "交通银行");
        put("10000", "中国电信");
        put("10016", "中国联通");
        put("95566", "中国银行");
        put("95595", "光大银行");
        put("12379", "国家预警信息发布中心");
        put("锤子商城", "锤子商城");
        put("10018", "中国联通");
        put("10198", "中国联通");
        put("95518", "中国人民保险");
        put("95598", "国家电网");
        put("95588", "工商银行");
        put("95539", "南方航空");
        put("95599", "中国农业银行");
        put("95522", "泰康人寿");
        put("12333", "人社局");
        put("95302", "南京银行");
        put("95580", "邮储银行");
        put("12301", "全国旅行社");
        put("95352", "德邦物流");
        put("95533", "中国建设银行");
        put("12366", "国家税务总局");
        put("95597", "华泰证券");
        put("95545", "中英人寿");
    }};

    private final static Map<String, String> dimOrgLoan = new HashMap<String, String>() {{
        put("农业银行", "农业银行");
        put("农行", "农业银行");
        put("95595", "农业银行");
        put("建设银行", "建设银行");
        put("建行", "建设银行");
        put("龙卡", "建设银行");
        put("95533", "建设银行");
        put("工商银行", "工商银行");
        put("工行", "工商银行");
        put("95588", "工商银行");
        put("工银融e借", "工商银行");
        put("交通银行", "交通银行");
        put("交行", "交通银行");
        put("95559", "交通银行");
        put("邮储银行", "邮储银行");
        put("邮政储蓄银行", "邮储银行");
        put("95580", "邮储银行");
        put("中国银行", "中国银行");
        put("中行", "中国银行");
        put("95566", "中国银行");
        put("招商", "招商银行");
        put("招行", "招商银行");
        put("招商信用卡", "招商银行");
        put("95555", "招商银行");
        put("浦发", "浦发银行");
        put("浦东发展银行", "浦发银行");
        put("中信银行", "中信银行");
        put("中信信用卡", "中信银行");
        put("光大银行", "光大银行");
        put("光大信用卡", "光大银行");
        put("光大商旅信用卡", "光大银行");
        put("光大阳光信用卡", "光大银行");
        put("阳光商旅信用卡", "光大银行");
        put("华夏银行", "华夏银行");
        put("华夏信用卡", "华夏银行");
        put("民生银行", "民生银行");
        put("广发银行", "广发银行");
        put("广发信用卡", "广发银行");
        put("兴业银行", "兴业银行");
        put("兴业信用卡", "兴业银行");
        put("平安银行", "平安银行");
        put("平安信用卡", "平安银行");
        put("浙商银行", "浙商银行");
        put("恒丰银行", "恒丰银行");
        put("恒丰银行信用卡", "恒丰银行");
        put("恒丰信用卡", "恒丰银行");
        put("渤海银行", "渤海银行");
        put("花旗", "花旗银行");
        put("渣打", "渣打银行");
        put("汇丰", "汇丰银行");
        put("南洋商业银行", "南洋商业银行");
        put("南洋", "南洋商业银行");
        put("东亚银行", "东亚银行");
        put("富邦华一", "富邦华一银行");
        put("国家开发银行", "国家开发银行");
        put("农业发展银行", "农业发展银行");
        put("农发行", "农业发展银行");
        put("苏州农商行", "苏州农商行");
        put("苏州农商行联名卡", "苏州农商行");
        put("无锡农村商业银行", "无锡农商行");
        put("无锡农商行", "无锡农商行");
        put("江西农商银行", "江西农商银行");
        put("山东农商银行", "山东农商行");
        put("山东农商行", "山东农商行");
        put("96668", "山东农商行");
        put("广州农商银行", "广州农商银行");
        put("东莞农商银行", "东莞农商银行");
        put("顺德农商银行", "顺德农商银行");
        put("顺德农商行联名卡", "顺德农商银行");
        put("江阴农商银行", "江阴农商行");
        put("江阴农商行", "江阴农商行");
        put("深圳农商银行", "深圳农商行");
        put("深圳农商行", "深圳农商行");
        put("安徽农信", "安徽农信");
        put("安徽农金", "安徽农信");
        put("泰隆商业银行", "泰隆银行");
        put("泰隆银行", "泰隆银行");
        put("民泰商业银行", "民泰银行");
        put("民泰银行", "民泰银行");
        put("浙江稠州商业银行", "稠州银行");
        put("稠州银行", "稠州银行");
        put("湖北消费金融", "湖北消费金融");
        put("循环贷", "湖北消费金融");
        put("菁英贷", "湖北消费金融");
        put("嗨享贷", "湖北消费金融");
        put("乐居贷", "湖北消费金融");
        put("招联", "招联消费金融");
        put("中邮钱包", "中邮消费金融");
        put("中邮消费", "中邮消费金融");
        put("金美信", "金美信消费金融");
        put("一秒消金", "一秒消金");
        put("中信消费金融", "中信消费金融");
        put("中原消费", "中原消费金融");
        put("中原消金", "中原消费金融");
        put("中银消费金融", "中银消费金融");
        put("中银消费贷", "中银消费金融");
        put("捷信", "捷信消费金融");
        put("农信消费金融", "农信消费金融");
        put("包银消费金融", "包银消费金融");
        put("华融消费金融", "华融消费金融");
        put("哈银消金", "哈银消金");
        put("哈银消费金融", "哈银消金");
        put("小米消费金融", "小米消费金融");
        put("尚诚消费金融", "尚诚消费金融");
        put("诚e借", "尚诚消费金融");
        put("平安消费金融", "平安消费金融");
        put("平安小橙花", "平安消费金融");
        put("广优消费金融", "广优消费金融");
        put("易佰消费金融", "易佰消费金融");
        put("海尔消费金融", "海尔消费金融");
        put("海尔消金商户", "海尔消费金融");
        put("够花", "海尔消费金融");
        put("盛银消费金融", "盛银消费金融");
        put("盛享贷", "盛银消费金融");
        put("苏宁消费", "苏宁消费金融");
        put("苏宁消金", "苏宁消费金融");
        put("苏享贷", "苏宁消费金融");
        put("蒙商消费金融", "蒙商消费金融");
        put("长银消费金融", "长银消费金融");
        put("长银五八消费金融", "长银消费金融");
        put("畅享贷", "长银消费金融");
        put("马上金融", "马上消费金融");
        put("马上消费", "马上消费金融");
        put("安逸花", "马上消费金融");
        put("优逸花", "马上消费金融");
        put("杭银消费", "杭银消费金融");
        put("尊享贷", "杭银消费金融");
        put("轻享贷", "杭银消费金融");
        put("晋商消费金融", "晋商消费金融");
        put("晋情贷", "晋商消费金融");
        put("随e贷", "晋商消费金融");
        put("借哇", "晋商消费金融");
        put("晋享分期", "晋商消费金融");
        put("幸福消费金融", "幸福消费金融");
        put("幸福花", "幸福消费金融");
        put("幸福买", "幸福消费金融");
        put("幸福结", "幸福消费金融");
        put("幸福帮", "幸福消费金融");
        put("北银消费", "北银消费金融");
        put("轻松贷", "北银消费金融");
        put("轻松付", "北银消费金融");
        put("锦程消费金融", "锦程消费金融");
        put("锦囊贷", "锦程消费金融");
        put("兴业消费金融", "兴业消费金融");
        put("阳光消费金融", "阳光消费金融");
        put("360信用生活", "360");
        put("360借条分期贷款", "360");
        put("360借条-贷款分期借款", "360");
        put("360借条", "360");
        put("360借款", "360");
        put("360微零花", "360");
        put("推有钱", "度小满金融");
        put("有钱花Lite", "度小满金融");
        put("有钱花", "度小满金融");
        put("度小满金融", "度小满金融");
        put("度小满", "度小满金融");
        put("京东金条", "京东金融");
        put("京东金融", "京东金融");
        put("京东白条", "京东金融");
        put("国美金融", "国美金融");
        put("国美易卡", "国美金融");
        put("美团借钱", "美团小贷");
        put("美团联名信用卡", "美团小贷");
        put("美团联名卡", "美团小贷");
        put("美团金融", "美团小贷");
        put("美团小帒", "美团小贷");
        put("美团月付", "美团小贷");
        put("美团生活费", "美团小贷");
        put("美团生意贷", "美团生意贷");
        put("去哪儿信用卡", "去哪儿信用卡");
        put("壹钱包", "壹钱包");
        put("一账通", "一账通");
        put("平安普惠", "平安普惠");
        put("平安金管家", "平安金管家");
        put("平安贷款", "平安贷款");
        put("平安", "平安集团");
        put("小米金融", "小米金融");
        put("小米贷款", "小米金融");
        put("小米金服", "小米金融");
        put("分期乐", "分期乐");
        put("乐信", "分期乐");
        put("买鸭", "分期乐");
        put("乐花卡", "分期乐");
        put("蚂蚁借款信用分期", "蚂蚁借款信用分期");
        put("花呗", "蚂蚁借款信用分期");
        put("借呗", "蚂蚁借款信用分期");
        put("宜人贷借款", "宜人贷借款");
        put("宜人贷", "宜人贷借款");
        put("宜信公司", "宜信公司");
        put("宜信", "宜信公司");
        put("沃钱包", "沃钱包");
        put("易借", "沃钱包");
        put("提钱游贷款", "提钱游贷款");
        put("提钱游", "提钱游贷款");
        put("榕树借条", "榕树借条");
        put("榕树", "榕树借条");
        put("小鹅贷款", "小鹅贷款");
        put("小鹅花钱", "小鹅贷款");
        put("信用钱包", "信用钱包");
        put("羊小咩", "信用钱包");
    }};


    public static String getOrgName(String address, String trimBody) throws Exception {
        if (hiveUdfRegExpEx(trimBody, "\\【[^\\】]*\\】") == 1) {
            return hiveUdfRegExReplace(hiveUdfRegexResStrInPos(trimBody, "\\【[^\\】]*\\】", 0), "\\【|\\】|\\[|\\]|\\［|\\］", "");
        }

        if (hiveUdfRegExpEx(trimBody, "\\[[^\\]]*\\]") == 1) {
            return hiveUdfRegExReplace(hiveUdfRegexResStrInPos(trimBody, "\\[[^\\]]*\\]", 0), "\\【|\\】|\\[|\\]|\\［|\\］", "");
        }

        if (hiveUdfRegExpEx(trimBody, "\\［[^\\］]*\\］") == 1) {
            return hiveUdfRegExReplace(hiveUdfRegexResStrInPos(trimBody, "\\［[^\\］]*\\］", 0), "\\【|\\】|\\[|\\]|\\［|\\］", "");
        }
        if (dimOrgName.get(address) != null && dimOrgName.get(address).length() > 0) {
            return dimOrgName.get(address);
        }
        return "";
    }

    public static String getTrimBodyFlags(String trimBody) throws Exception {
        return "" + hiveUdfRegExpEx(trimBody, "公益短信|中国移动|中国联通|中国电信|抖音(.*)发了新视频|^\\d$")
                + hiveUdfRegExpEx(trimBody, "已(经)?(严重)?逾期|已超(过|出).*(日|期限)|已超期|(处理|结清)逾期欠款|已欠款|逾期超时|严重逾期|逾期金额|处于逾期(状态|事宜)")
                + hiveUdfRegExpEx(trimBody, "(今|明|将|还有|剩).*(到期|满期)|还款日")
                + hiveUdfRegExpEx(trimBody, "未(能)?通过|(申请|借款).*(失败|拒绝)|不符合|审(批|核)拒绝|(未|未能).*(获).*额度|未满足.*申请要求|未达到.*标准")
                + hiveUdfRegExpEx(trimBody, "申请成功|已通过审核")
                + hiveUdfRegExpEx(trimBody, "[^如](还款|扣款|划扣)(失败|不成功|未成功)|(无法|未能)(还款|扣款|划扣)")
                + hiveUdfRegExpEx(trimBody, "已成功(还款|扣款)|(已|自动)(还款|扣款)成功")
                + hiveUdfRegExpEx(trimBody, "已(于)?[0-9-]*(提交)?(放款|发放)|(^未|预约)(借款成功|成功放款|放款成功)|(完成贷款|正在)放款|放款过渡户|放款(过渡户|暂账户)(.*)来账|放款账户(.*)完成转存交易|放款收入|\\([(\\u4e00-\\u9fa5)\\w-^\\)]*放款\\)");
    }

    public static int getOrgNameFlags(String orgName) throws Exception {
        return hiveUdfRegExpEx(orgName, "交警|百度帐号|luckin coffee|(腾讯|爱奇艺|优酷)(视频)?VIP|疾病预防控制中心|疫情防控|交通运输厅|快递|高频骚扰电话防护|气象局|丰巢|菜鸟驿站|10086|10101|10000|(流量|话费)(.*)?提醒|电信|短信|卡劵|移动|联通|通卡|社保卡|工信|旗舰店|同花|信息|信访|ETC|高速|自来水|飞信|通信|王卡|停机|连信|学信网|卫生|集享卡|迪卡侬|货拉拉");
    }

    public static int getTradeType(String trimBody) throws Exception {
        if (hiveUdfRegExpEx(trimBody, "(交易|还款|扣款)失败|(余额|额度)不足") == 1) {
            return 1;
        }

        if (hiveUdfRegExpEx(trimBody, "收入|入账|转入|存入|来账") == 1
                && hiveUdfRegExpEx(trimBody, "余额不足|有效|涨|作废|赠|失败|转出|过期将影响信用额度|扣款|还款|借款|放款|收入(飞|暴|涨涨)涨|保底收入|充值|诈骗|收入同比增长|查(看|收)|贷款|申请|消费|收入翻倍|小程序|营业厅|保费|保单|额外收入|现金额度|入账欠款|(现金|中)?奖(励)?") == 0) {
            return 2;
        }

        if (hiveUdfRegExpEx(trimBody, "扣款|还款[^日]|贷款支出") == 1
                && hiveUdfRegExpEx(trimBody, "待还款|申请|应还|送|红包") == 0) {
            return 3;
        }

        if (hiveUdfRegExpEx(trimBody, "应还(款)?(额|金额|总额)?(为)?|账单") == 1
                && hiveUdfRegExpEx(trimBody, "送|红包") == 0) {
            return 4;
        }

        if (hiveUdfRegExpEx(trimBody, "[^生活]支出|[^日常]消费|交易[^密码]|转出|取出|转账|快捷|支付[^宝]|ATM取款") == 1
                && hiveUdfRegExpEx(trimBody, "失败|余额不足") == 1) {
            return 5;
        }

        if (hiveUdfRegExpEx(trimBody, "(取现(人民币|RMB|￥)?|预借现金)[0-9.,-]+") == 1) {
            return 6;
        }

        return 7;
    }

    public static String getOrgLoan(String orgName, String trimBody) throws Exception {
        if (dimOrgLoan.get(orgName) != null && dimOrgLoan.get(orgName).length() != 0) {
            return dimOrgLoan.get(orgName);
        }
        if (hiveUdfRegExpEx(orgName, "短信分期") == 1 && hiveUdfRegExpEx(trimBody, "工资") == 1) {
            return "工商银行";
        }
        if (hiveUdfRegExpEx(orgName, "360") == 1 && hiveUdfRegExpEx(trimBody, "360借条") == 1) {
            return "360";
        }
        if (hiveUdfRegExpEx(orgName, "蚂蚁集团") == 1 && hiveUdfRegExpEx(trimBody, "备用金") == 1) {
            return "蚂蚁集团";
        }
        if (hiveUdfRegExpEx(orgName, "美团") == 1 && hiveUdfRegExpEx(trimBody, "美团生活费|您领用的.*本期应还|您领用的.*于.*成功还款") == 1) {
            return "美团小贷";
        }
        if (hiveUdfRegExpEx(orgName, "众安保险") == 1 && hiveUdfRegExpEx(trimBody, "您由众安保险承保的.*借款") == 1) {
            return "众安保险";
        }
        if (hiveUdfRegExpEx(orgName, "苏宁") == 1 && hiveUdfRegExpEx(trimBody, "快递|包裹") == 1) {
            return "苏宁金融";
        }
        return orgName;
    }

    public static int getOrgType(String orgName, String trimBody) throws Exception {
        String orgLoan = getOrgLoan(orgName, trimBody);

        if (hiveUdfRegExpEx(orgLoan, "农业银行|建设银行|工商银行|交通银行|邮储银行|中国银行") == 1) {
            return 1;
        }

        if (hiveUdfRegExpEx(orgLoan, "招商银行|浦发银行|中信银行|光大银行|华夏银行|民生银行|广发银行|兴业银行|平安银行|平安银行|浙商银行|浙商银行|恒丰银行|渤海银行") == 1) {
            return 2;
        }

        if (hiveUdfRegExpEx(orgLoan, "花旗|渣打|汇丰|南洋商业银行|南洋|东亚银行|富邦华一") == 1) {
            return 3;
        }

        if (hiveUdfRegExpEx(orgLoan, "国家开发银行|农业发展银行|进出口银行") == 1) {
            return 4;
        }

        if (hiveUdfRegExpEx(orgLoan, "金城银行|华瑞银行|网商银行|民商银行|微众银行|三湘银行|富民银行|新网银行|中关村银行|亿联银行|众邦银行|华通银行|蓝海银行|苏宁银行|客商银行|新安银行|振兴银行|裕民银行|锡商银行|百信银行") == 1) {
            return 5;
        }

        if (hiveUdfRegExpEx(orgLoan, "农商行|农商银行|农村商业银行|秦农银行|瑞丰银行|黄河银行|江南银行|鄞州银行") == 1) {
            return 6;
        }

        if (hiveUdfRegExpEx(orgLoan, "农信|安徽农金|陕西信合|甘肃信合") == 1) {
            return 7;
        }

        if (hiveUdfRegExpEx(orgLoan, "村镇银行|中银富登|融泰村银") == 1) {
            return 8;
        }

        if (hiveUdfRegExpEx(orgLoan, "北京银行|昆仑银行|天津银行|河北银行|邢台银行|唐山银行|秦皇岛银行|沧州银行|承德银行|邯郸银行|保定银行|廊坊银行|衡水银行|张家口(银行|信用卡)|晋商银行|山西银行|内蒙古银行|乌海银行|鄂尔多斯银行|蒙商银行|辽沈银行|盛京银行|锦州银行|葫芦岛银行|大连银行|鞍山银行|抚顺银行|丹东银行|营口银行|阜新银行|铁岭银行|朝阳银行|盘锦银行|本溪银行|吉林银行|龙江银行|哈尔滨银行|上海银行|江苏银行|南京银行|苏州银行|江苏长江商业银行|杭州银行|宁波银行|温州银行|嘉兴银行|湖州银行|绍兴银行|金华银行|台州银行|浙江泰隆商业银行|泰隆银行|浙江民泰商业银行|民泰银行|浙江稠州商业银行|宁波通商银行|宁波东海银行|徽商银行|厦门国际银行|海峡银行|厦门银行|泉州银行|江西银行|九江银行|赣州银行|上饶银行|齐鲁银行|济宁银行|青岛银行|临商银行|枣庄银行|东营银行|潍坊银行|烟台银行|齐商银行|日照银行|莱商银行|德州银行|威海市商业银行|泰安银行|中原银行|郑州银行|洛阳银行|平顶山银行|焦作中旅银行|湖北银行|汉口银行|华融湘江银行|长沙银行|广州银行|华润银行|东莞银行|广东南粤银行|广东华兴银行|广西北部湾银行|柳州银行|桂林银行|重庆银行|重庆三峡银行|四川银行|成都银行|长城华西银行|绵阳市商业银行|自贡银行|泸州银行|乐山市商业银行|四川天府银行|宜宾市商业银行|遂宁银行|雅安市商业银行|达州银行|贵州银行|贵阳银行|富滇银行|曲靖市商业银行|云南红塔银行|西藏银行|长安银行|西安银行|甘肃银行|兰州银行|宁夏银行|石嘴山银行|青海银行|新疆银行|乌鲁木齐银行|库尔勒银行|新疆汇和银行|哈密市商业银行|稠州银行") == 1) {
            return 9;
        }

        if (hiveUdfRegExpEx(orgLoan, "银行") == 1) {
            return 10;
        }

        if (hiveUdfRegExpEx(orgLoan, "湖北消费金融|招联消费金融|中邮消费金融|金美信消费金融|一秒消金|中信消费金融|中原消费金融|中银消费金融|捷信消费金融|农信消费金融|包银消费金融|华融消费金融|哈银消金|小米消费金融|尚诚消费金融|平安消费金融|广优消费金融|易佰消费金融|海尔消费金融|盛银消费金融|苏宁消费金融|蒙商消费金融|长银消费金融|马上消费金融|杭银消费金融|晋商消费金融|幸福消费金融|北银消费金融|锦程消费金融|兴业消费金融|阳光消费金融") == 1) {
            return 11;
        }
        if (hiveUdfRegExpEx(orgLoan, "点点|美团生意贷|去哪儿信用卡|壹钱包|一账通|平安普惠|平安金管家|平安贷款|平安集团|小米金融|云联掌柜|众安管家|58好借|小米随星借|滴滴金融|支付宝|还呗|省呗|陆金服") == 1) {
            return 12;
        }
        if (hiveUdfRegExpEx(orgLoan, "众安贷|苏宁金融|OPPO钱包|微博|民生易贷|满帮金融|360|拍拍贷|京东金融|国美金融|度小满金融|蚂蚁借款信用分期|vivo钱包|翼支付|美团小贷|分期乐|360贷款|51公积金借款|51即刻金融|51即刻有|51人品贷|51信用卡管家|KOO钱包|爱钱进|百万钱包|百万钱包贷款借钱|佰惠优品|达飞云贷|大白汽车分期|豆豆钱|读秒钱包|凡普信贷|分期贷|好车e贷|恒易融|花无缺大学贷|环球黑卡|活力花|及贷|即刻金融|捷信|捷信金融商家|借款大王|玖富钱包|玖富万卡|玖富万卡贷款借钱|卡卡贷|卡牛瑞贷|卡牛信用管家|卡易还|快易花|来分期|来分期商城版|浪小花|乐享借|乐信钱包|买买乐购|你我贷借款|平安好贷|钱站|人品贷|人品贷极速版|人人贷借款|任意花|闪电借款|闪银|时光分期|顺丰金融|松紧贷|松鼠金融借款|通联好老板|万达贷|万达普惠|万达普惠极速版|微博分期|微贷借款|维信卡卡贷|维信闪贷|喜鹊快贷|乡助|小花钱包|小赢分期|小赢|小赢卡贷|小赢卡贷贷款借钱|小赢卡贷-贷款借钱|小赢理财|携程|携程借款|携程金融|新浪分期|信用飞|洋钱罐借款|摇钱花|宜人贷借款|宜人普惠|易美付|易鑫金融|友信信贷|原子贷|芸豆借款|掌上新华|众安小贷") == 1) {
            return 13;
        }
        if (hiveUdfRegExpEx(orgLoan, "蚂蚁集团|58金融|宜信公司|众易贷|唯品金融|DOU分期|新橙优品|新浪金融|众安保险|宜享花|我来数科|榕树贷款|你我贷|万卡|小象优品|人品钱包|融360|小闪分期|得意花|我的公款|新大陆金融|现金白卡|月光侠分期|荷包Pro|助力钱包|U钱包|贷上钱|阔啦|信用管家借钱|花卡分期|金山金融|借款3600|比利宝|借购消费|分期借款花|用钱罐|秒贷借钱|给你花|花友|趣用|富誉万卡|幸福花|满分|买单侠分期|借悦|优品鲸花|好融易|榕易有钱|趣用贷款|即分期超G会员|芝麻分期|任享用|佰汇花|周薪薪|宝宝分期|应急分期|手机借钱|拍拍借款|用钱贷|百易生活|豆豆借钱|贝贷|财小神|趣钱花-分期贷款|通通分期|金 橘 子|钱多美|钱花花|乐惠花|亲呗|优贝分期|信用借款|借点钱贷款|咚咚优品|天眼|好会借|富民融通|小白分期|小花分期|小雨点闪贷|小鱼福卡|山桃街|微粒贷|快来闪借|急时金|极风|汇鑫街|爱又米|用点钱|移动手机贷|七亿入口|信诚生活|借你花|借条|去哪借|周转金|城一代|备用金借款|安易花|小额贷款花|小黑鱼-会员消费平台|微借贷|急 用先锋|捷顺爱分期|来享花|极迅花|柚卡|榕树借条|汇中贷|考拉消消赚|花生口袋卡|薪朋友|融呗分期|贷你无忧|连连来钱|钞享借|钱伴|锦囊贷|随借|77信用|万富黑卡|万银口袋|信用无忧|信用花贷款|借贷宝|大麦钱包|好借款|安家派|富宝袋|彩虹花呗|微花贷款|急用钱花|招贷|捷优花|易钱包|省点花|花薪|蚂蚁借款|鑫享通|闪电信用|360分期借款花|乐享借钱|乐享分期|享誉分期|优逸花|信用查询|奇妙商场嘉年华|好信多|小6分期|小鹅花钱|小鹅贷款|徽常有财|快融钱包|橄榄树|满分消费|环球钱包|秒想借|美联分期|联银花|融好借|融小六|闪易花|随享用|中安信业|农夫借钱|到手|功夫贷|喵享借|嗨袋|国融鼎信|太享贷|小象省钱花|快享花|急用花|融享租|趣借|金盈万卡|银满贯|亿帮 管 佳|任性用|优米花|借蛙|借钱能手|分期借钱|小通生活|惠分期-借款|拿趣花|橙薪分期|牛牛万卡|聚鑫易卡|衣食贷|超超Bank|速趣花|银惠通|龙信易购|人品借款|你我分期贷|信优享|吉多钱|好借分期|好时贷|安逸借钱|小熊卡卡|小黑鱼|微粒有钱|急享贷|指尖阳光|蜜柚分期|趣闪借|顺易分期|马上到账|U呗分期|万惠分期|乐借贷款|乐花分期|任性花|众银家|分期贷款花|天天秒借|宜有钱|小橙信|应急优选|微贷借钱|快贷|悦借|易借速贷|易帮。管家|暖暖钱包|现金借钱|瓜子万卡|畅快|立即分期|虫虫分期|蚂蚁借钱信用分期|融易分期|贷款360|鼠乾 罐|360分期借钱|乐花卡|买买分|信业帮|借钱花吧|备用金借贷|好唶 由品|好捷分期|小雨点闪贷-借钱贷款|小额借钱花|新呗分期|易达|海洋分期|甜桔消费|立信分期|花鸭借钱|花鸭|购满分期|趣用呗|车贷在线|金日快下|钱咖|闪零易借|今借到|去分期|壹秒花|备用金|天美贷|很好借|急用钱|我爱卡|民生助粒|艾米分期|速分期|魔借|乐分期|信用花花|分期花|够花|大地时贷|小智金服|小鹿普惠|惠享金|惠借|搜狗借钱|晋享钱包|普信万卡|智享通|极信钱包|甜橙财富|芝麻借款分期|蚂蚁借条信用贷款|趣前行|还享花|金山贷款|乐分期贷款|亚联财贷款|信用转转贷款|喵享乐|大棠优品|大鹅贷款分期|微贷款|微贷钱包|惠借贷款|惠域U卡|新信钱包|极融借款|派金花|淘金荟|牛牛分期|秋贝金融|秒享有钱|聚融分期|鑫梦享|钱有道|闪借|闪借备用金|飞鑫琼宝|鲸惠花卡|人品借钱|人品分期|信融分期|借钱花|分期信用|前程分期|好省钱包|微享加|微享加-贷款借钱|微享加贷款平台|易开花|普咚花|普惠快信|来付吧|欢太金融|现金巴士|用钱宝|盈盈有钱|秒信卡|空手到|米团|美宜贷|花花钱包借钱贷款|融租优品|融银分期|随手花|顺风优品|飞贷|鲸森优品|麦芒信用管家") == 1) {
            return 14;
        }
        if (hiveUdfRegExpEx(orgLoan, "臻有钱|沃钱包|芝麻好信|微博借钱|卡贷|铂银贷|趣钱花|借点钱|恒易贷|有信钱包|极融|分期易|放心借|现金借款|招集令|信用钱包|白猫贷|微博钱包|好享借|点点|36O借条|MG金掌柜|PPmoney网贷|中安信业贷款|云闪贷|享易钱包|信用生活|借贷家|友金云贷|合众分期|周转易|多多存钱罐|天天好贷|好享分期|安心袋|小钱门|微融宝|快售宝|急周转|招商E贷|招商盾|有用无忧|来分期借钱|汇鸿分期|考拉分期贷款|芝麻招財宝|连连普惠|金 橘子|金银港|金鱼好记|鑫e代|钱多多|360周转灵|PP管家|乐猫智服|乐花花|亿贝卡|优速花|信用安逸小花钱包|信用宝|借 呗|借了吗贷款|借款呗|借钱360|分期还款|卡分期|及贷借款|多多生活|大象信用|小白银|平安E贷|快借分期|快钱钱包|抖金钱包|提现管家|放心借钱|数 乾贯|新乐分期|普惠快捷|江山金服|猛犸象|现金借条分期贷|立借|腾付通|芝麻借款借条|花花借钱贷款|薪河普惠|蚂蚁借款信用花|蜀信e惠生活|融信|随享分期|My钱包|PPmoney出借|一当来客|乐易借|买单侠|今日必放|信小蜜|借钱贷款呗|共享备用金|兴e贷|可享分期|合利宝Pro|吉致管家|吉象普惠|君嘉好车|好运分期|居易分期|平.安.信.贷|急用钱借钱|惠花|提钱游贷款|搜易贷|放心花|旺卡猫|易 花 宝|普信通|普普优借|杭州e融|白花分期|芝麻信用借钱|蚂蚁信用|趣花借钱|趣花分期|轻借|轻松花|还到|速金服|金牛花呗|鑫考拉|麦花分期|云企贷|享要花|京银猪|任性借|优乐分期|信好有你|借了么|借钱管家|大鹅分期|好想借|安心借|小店邦|幑柆货|开鑫花|微沙信用|快批|急贷趣玩|恒鼎融|搜搜贷|文文闪花|普惠有借|曹操贷|柠檬优选|水莲金条|淘花花|淘钱宝|白 宝 借|百事普惠|豆豆金条|邮储信贷|邮我行|闪电速贷借款|陌陌 白条|马上借款花|马上消费|JDJT|MYJB|万恒无忧|人.人.貸|人品钱袋|借款喵|四 海 .救急|大红牛|小米借贷|小袋鼠|徽柆.货|快客金服|恒慧融|扬帆配资|普惠金融|比融|海马应急|润心贷|猪猪分期|现金借款王|禾诚分期|秒秒借|网商点点通|芝麻白条|银杏分期|阳光钱袋|颐尔信|鸿运借呗|享你有|享宇钱包|优亿金融|余利购|佰事有借|佰仟买买钱包|信掌柜|信用借|借贷王|借钱分期贷|借钱站台|农商e货|几多钱|卡多多|卡牛信用卡管家|友借|和信普惠|安家趣花|容易借|小鼠花花|平安财富宝|应急小额借贷|快来借|快贷360|惠花花|手机人人贷款借钱|搜狗手机助手（恒易贷）|星华汇|海棠分期|点贷|现金分期贷款|翼龙贷借款|联璧金融|芝麻算力|花咯分期|菠萝贷|蚂蚁钱罐|融e租|速贷|邮政·金融|鑫悦钱包|钱在银座|钱橙似锦|银穗穗贷款|闪呗分期|麦子分期|黑鱼京分期|51借款|58优品|一秒分期|万卡猫|万达通|云好借|借款钱包|全球黑卡|分期借|分期花呗|召金通|国民分期|多享分期|大地展业|好贷分期|小月亮|小橙借款分期|小牛贷|小花花钱包|快刻周转|新呗贷款|易下分期|来钱宝|来钱猫|每日应急|秒借|联合钱包|荷包|蚂蚁速用|融易借|证大前前|贷款巴士|跳跳鱼|车贷e通|金好借|金小帮|金满意|银豹分期|闪零易贷|风控平台|黑兔信用|2021特邀版|信用分期|信花|借钱花借款|卡转客|向前金服|周转借钱|多宝鱼|大额分期贷款|小伍钱包|小额闪电贷款|平安易贷|应急金|微柆货|愉快还啦|收钱呗|新一贷|易借款|有鱼借|永辉金融|渠易宝|牧鱼分期|白条分期|立享贷|翼龙贷财富|芝麻速借|花无缺|萝莉贷|蚂蚁借钱信用花|蚂蚁花呗|诚易好借|车贷云|金卡优品|银谷普惠|闪闪快借|阳光钱袋升级版|陕西应急|颂车网|鲸钱包|51易花|MYJF|万家乐惠|乐贷款|京融白 条|今日好借|信可花|卡宝贝|合墨数据|呗呗钱包|大额 应急|小助钱包|小鱼儿|应急必下|恒易借|放心贷|易答在线|普咚借|有利网|来分期借款|汇丰金融|泛回收|澄薪分期|爱米花|考拉信用|联动闪银|聚享钱包|聚宝卡|蚂蚁小贷|财神爷|金融超市|钱司机|随心花|雪豹钱包|乐房生活|任易分期|优米|优质融|信用上海|借款360导航|全网快贷|农商E货|准贷宝|分期通|即有生活|即用钱袋|及借贷|吉祥借款|多乐帮|多财多亿|够用|小豆分期|小雨点商贷|小鱼优品|开薪小宝|掌贷|放心借款|无忧贷款|易速借钱|柠檬分期|核桃树|橙意钱包|民生e货|爱白条|福卡分期|红锦鲤|羚羊财富(投资·赚钱)|聚富分期|聚鑫花|芝麻借钱分期借款|花生旺客|诚心帮|贷小二|达融分期|金葫芦|金赢猪|鼎融易|CC卡管家|一点分期|万卡钱包|优智花|分付君|华夏普惠|博民快易贷|呱呱分期|商e贷|四海 救急|打个借条|来钱啦|极速熊猫|汇卡卡|玖福分期pro|益邦 管家|美栗|腾狐生活|花呗借钱|菜鸟极速|萌分期|袋上乾|贝贝钱|财享花|钱迹|隆易|随手分期|雪花优品|66钱庄借款|99贷|ACU钱包|信用精灵借钱助手|借呗|借呗还呗|借点周转|农商e融|包小微|卡卡速还|友金帮|天翼花|小恒钱包|帮你借钱花|彩虹 分期|微微贷|快鱼分期|悦平台|惠虹商城|无忧贷|时运贷|桔子借钱|民生e贷|灵活买|番茄信用|疾风钱包|百亿金服|秒借贷|聚财宝|聚银宝|芝麻信用贷|花分期|花花购|花钱应急|蓝琼花花|蓝薪卡|融E贷|融客+|金猫|PPmoney借款|中和金服|任意贷|信用来花|分期借贷贷款|助力分期|十万火急|即享万卡|大黄蜂|天下粮仓|宜家生活贷|小口袋|小财象|小通币咚|平安DO|平安新一贷|快借贷款|推借|新易贷微贷款|普贷分期|海印金服|海逸花|私房钱|立保通|笑嘻嘻|聚优米|航旅分期|花呗|蚂蚁借款分期贷款|贝壳金服|运呗|速借分期|速易贷|速贷现金贷款借款|钱包易贷|2345贷款王|360借款导航|51借款管家|51卡宝|e农享|万象黑卡|亿邦 管家|今日普惠|便易通|借点钱贷款借钱|借钱3600|凤凰智信|咖啡易融至尊版|壹亿卡|小象分期贷款|微贷网|想花钱|慧亿|手机借钱花|掌上金东|有信分期|有银子|畅行贷|秒贷款分期借钱|职享花|胞分期|蚂蚁分期贷款呗|蚂蚁贷款借呗|贝多多|钱快来|阳光普贷|零零花|风之谷|风花雪月") == 1) {
            return 15;
        }

        return 16;

    }

    public static int getPhoneTag(String address) throws Exception {
        String formatAddress = hiveUdfRegExReplace(address, "^86|^\\+86", "");
        if (formatAddress != null && formatAddress.length() >= 3
                && hiveUdfRegExpEx(
                formatAddress.substring(0, 3),
                "134|135|136|137|138|139|147|148|150|151|152|157|158|159|172|178|182|183|184|187|188|195|197|198|130|131|132|155|156|166|167|175|176|185|186|196|133|149|153|173|177|180|181|189|190|191|193|199|192") == 1) {
            return 1;
        }
        return 0;
    }

    public static int getSmsBankTag(String body, Integer smsTag) throws Exception {
        String sms_feature_org = "";


        if (hiveUdfRegExpEx(body, "\\【[^\\】]*\\】") == 1) {
            sms_feature_org = hiveUdfRegExReplace(hiveUdfRegexResStrInPos(body, "\\【[^\\】]*\\】", 0), "\\【|\\】|\\[|\\]|\\［|\\］", "");
        }

        if (hiveUdfRegExpEx(body, "\\[[^\\]]*\\]") == 1) {
            sms_feature_org = hiveUdfRegExReplace(hiveUdfRegexResStrInPos(body, "\\[[^\\]]*\\]", 0), "\\【|\\】|\\[|\\]|\\［|\\］", "");
        }

        if (hiveUdfRegExpEx(body, "\\［[^\\］]*\\］") == 1) {
            sms_feature_org = hiveUdfRegExReplace(hiveUdfRegexResStrInPos(body, "\\［[^\\］]*\\］", 0), "\\【|\\】|\\[|\\]|\\［|\\］", "");
        }

        if (!(ReUtil.findAllGroup0("【", body).size() == 1
                || ReUtil.findAllGroup0("\\[", body).size() == 1)) {
            sms_feature_org = "";
        }

        if (hiveUdfRegExpEx(body, "信用卡") == 1
                || hiveUdfRegExpEx(sms_feature_org, "银行|农商|农信|城商|信合|中行|建行|工行|农行") == 1) {
            if(smsTag >= 1 && smsTag <= 3) {
                return smsTag;
            } else {
                return 0;
            }
        }
        if (smsTag >= 1 && smsTag <= 3) {
            return smsTag+3;
        }
        return 0;
    }

    public static int getSmsTag(String sendType, String body, String salary) throws Exception {

        //未分类
        if (!"1".equals(sendType)) {
            return 0;
        }
        int index = body.replace(",", "").indexOf(salary);

        Boolean flag1 = false;
        Boolean flag2 = false;
        Boolean flag3 = false;
        Boolean flag4 = false;

        if (hiveUdfRegExpEx(body, "(已|已经|已产生|当前|仍|仍然)(逾期|逾|拖欠|欠|欠款)((超|超过|大于|满)?)([0-9]+)天") == 1
                || hiveUdfRegExpEx(body, "(逾期|逾|拖欠|欠|欠款)(已|已经|已产生|当前|仍|仍然)((超|超过|大于|满)?)([0-9]+)天") == 1) {
            flag1 = Integer.parseInt(hiveUdfRegexResStrInPos(body, "([0-9]+)天", 1)) >= 60;
        }
        if (hiveUdfRegExpEx(body, "(已|已经|已产生|当前|仍|仍然)(逾期|逾|拖欠|欠|欠款)((超|超过|大于|满)?)(.*)个月") == 1
                || hiveUdfRegExpEx(body, "(逾期|逾|拖欠|欠|欠款)(已|已经|已产生|当前|仍|仍然)((超|超过|大于|满)?)(.*)个月") == 1) {

            flag2 = hiveUdfRegExpEx(hiveUdfRegexResStrInPos(body, "(逾期|逾|拖欠|欠|欠款)(.*)个月", 2), "一|1") == 0
                    || hiveUdfRegExpEx(hiveUdfRegexResStrInPos(body, "(逾期|逾|拖欠|欠|欠款)(.*)个月", 2), "10|11|12|十") == 1;

            flag3 = hiveUdfRegExpEx(hiveUdfRegexResStrInPos(body, "(逾期|逾|拖欠|欠|欠款)(.*)个月", 2), "一|1") == 1
                    && hiveUdfRegExpEx(hiveUdfRegexResStrInPos(body, "(逾期|逾|拖欠|欠|欠款)(.*)个月", 2), "10|11|12|十") == 0;

        }

        if (hiveUdfRegExpEx(body, "(逾期|逾|拖欠|欠|欠款)(已|已经|已产生|当前|仍|仍然)((超|超过|大于|满|高达)?)([0-9]+)天") == 1
                || hiveUdfRegExpEx(body, "(已|已经|已产生|当前|仍|仍然)(逾期|逾|拖欠|欠|欠款)((超|超过|大于|满|高达)?)([0-9]+)天") == 1) {
            flag4 = Integer.parseInt(hiveUdfRegexResStrInPos(body, "([0-9]+)天", 1)) < 60;
        }


        //return 1 借贷严重失信
        if (
                hiveUdfRegExpEx(body, "(余额不足)((导致|致使|致)?)(扣划|扣款|划扣)(失败|(不|不能|无法|未|未能)(通过|成功))") == 0
                        && hiveUdfRegExpEx(body, "友情提示|友情提醒|温馨提示|温馨提醒|提醒您|提醒广大市民|提醒市民|公益短信|财政局|管理局|税务|档案库|断卡") == 0
                        && hiveUdfRegExpEx(body, "贷|借|债|分期|信用卡|账单|款项|欠款|还款|银行|融资|支付宝") == 1
                        && (
                        flag1
                                || flag2
                                || (hiveUdfRegExpEx(body, "(严重|恶意|已久|长期|多次|屡次|数次|蓄意|重度)(逾期|拖欠|欠款|违约|失信|逃避|拒接|催缴|催收|催讨|催 缴)") == 1
                                || hiveUdfRegExpEx(body, "(逾期|拖欠|欠款|违约|逃避|拒接|失信|催缴|催收|催讨|催 缴)(严重|恶意|已久|长期|多次|屡次|数次|蓄意|重度)") == 1
                                || hiveUdfRegExpEx(body, "传票|开庭通知|法刑初字|法诉通知|律所通知") == 1)
                )
        ) {
            return 1;
        }

        //return 2 借贷一般逾期
        if (hiveUdfRegExpEx(body, "贷|借|债|分期|信用卡|账单|款项|欠款|还款|银行|融资|支付宝") == 1
                && (flag4 || flag3 || hiveUdfRegExpEx(body, "(已|已经|已产生|当前|仍|仍然)(逾期|拖欠|欠)") == 1)) {
            return 2;
        }

        //return 3 借贷申请被拒
        if (hiveUdfRegExpEx(body, "借|贷|信用卡|授信|额度|提额|分期|放款") == 1
                && hiveUdfRegExpEx(body, "您|你") == 1
                && (
                hiveUdfRegExpEx(body, "(综合)(评分|资质|信用|评估)(较低|过低|不足|不佳|不良|不符)") == 1
                        || hiveUdfRegExpEx(body, "(申请|审批|审核|授信|放款|借款|贷款)(失败|拒绝|被拒|((不|不予|不能|无法|未|未能)(通过|核准|批准|成功)))") == 1
                        || hiveUdfRegExpEx(body, "(不|不予|不能|无法|未|未能)(申请|审批|审核|授信|放款|借款|贷款)(通过|核准|批准|成功)") == 1
                        || hiveUdfRegExpEx(body, "(不|不予|不能|无法|未|未能)(通过|核准|批准)((您的|你的)?)(申请|审批|审核|授信|放款|借款|贷款)") == 1
        )
                && hiveUdfRegExpEx(body, "系统繁忙|审批故障|系统异常|系统故障|收款失败|账户限额") == 0
        ) {
            return 3;
        }

        //return 4 额度不足交易失败
        if (hiveUdfRegExpEx(body, "额度不足") == 1
                && hiveUdfRegExpEx(body, "交易|消费|刷卡|支付") == 1
                && hiveUdfRegExpEx(body, "失败|((不|不能|无法|未|未能)(成功|通过))") == 1
                && hiveUdfRegExpEx(body, "还款(失败|((不|不能|无法|未|未能)(成功|通过)))") == 0) {
            return 4;
        }

        //return 5 余额不足还款失败
        if (hiveUdfRegExpEx(body, "(还款|还.款|还 款)(申请?)(失败|((不|不能|无法|未|未能)(成功|通过)))") == 1
                && hiveUdfRegExpEx(body, "即将|将于|将从") == 0) {
            return 5;
        }

        //return 6 代发工资
        if (body.contains("工资")
                && ReUtil.contains("入账|收入|工资交易|代发|存入|到账|转入|金额|增加|存|代收|收款|发放|转存|(分).*?(工资)|(于).*?(工资)", body)
                && !ReUtil.contains("理财|支付|支取|支出", body)
                && !StringUtils.isEmpty(salary)
                && !"-".equals(body.substring(Math.max(index - 1, 0), index))
        ) {
            return 6;
        }

        //return 7 生活欠费逾期
        if (hiveUdfRegExpEx(body, "能源|水费|用水|供水|水网|水务|停水|断水|水力|自来水|电费|用电|供电|电网|停电|断电|电力|煤|燃气|租金|物业|车费|停车|ETC|宽带|话费|停机|电视|套餐|营业厅|手机账单|医疗|医保|社保|保险|保单|发货|订单|证件") == 1
                && hiveUdfRegExpEx(body, "欠|逾期") == 1) {
            return 7;
        }

        //未分类
        return 0;
    }


}



